﻿
namespace HanderlaarsBonnen
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Data;
    using System.Linq;
    using System.ServiceModel.DomainServices.EntityFramework;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Server;


    // Implements application logic using the VoucherDbEntities1 context.
    // TODO: Add your application logic to these methods or in additional methods.
    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
    // Also consider adding roles to restrict access as appropriate.
    // [RequiresAuthentication]
    [EnableClientAccess()]
    public class VoucherModelDS : LinqToEntitiesDomainService<VoucherDbEntities1>
    {

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'BTC' query.
        public IQueryable<BTC> GetBTC()
        {
            return this.ObjectContext.BTC;
        }

        public void InsertBTC(BTC bTC)
        {
            if ((bTC.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(bTC, EntityState.Added);
            }
            else
            {
                this.ObjectContext.BTC.AddObject(bTC);
            }
        }

        public void UpdateBTC(BTC currentBTC)
        {
            this.ObjectContext.BTC.AttachAsModified(currentBTC, this.ChangeSet.GetOriginal(currentBTC));
        }

        public void DeleteBTC(BTC bTC)
        {
            if ((bTC.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(bTC, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.BTC.Attach(bTC);
                this.ObjectContext.BTC.DeleteObject(bTC);
            }
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Consumer' query.
        public IQueryable<Consumer> GetConsumer()
        {
            return this.ObjectContext.Consumer;
        }

        public void InsertConsumer(Consumer consumer)
        {
            if ((consumer.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(consumer, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Consumer.AddObject(consumer);
            }
        }

        public void UpdateConsumer(Consumer currentConsumer)
        {
            this.ObjectContext.Consumer.AttachAsModified(currentConsumer, this.ChangeSet.GetOriginal(currentConsumer));
        }

        public void DeleteConsumer(Consumer consumer)
        {
            if ((consumer.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(consumer, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.Consumer.Attach(consumer);
                this.ObjectContext.Consumer.DeleteObject(consumer);
            }
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Gewonnenvoucher' query.
        public IQueryable<Gewonnenvoucher> GetGewonnenvoucher()
        {
            return this.ObjectContext.Gewonnenvoucher;
        }

        public void InsertGewonnenvoucher(Gewonnenvoucher gewonnenvoucher)
        {
            if ((gewonnenvoucher.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(gewonnenvoucher, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Gewonnenvoucher.AddObject(gewonnenvoucher);
            }
        }

        public void UpdateGewonnenvoucher(Gewonnenvoucher currentGewonnenvoucher)
        {
            this.ObjectContext.Gewonnenvoucher.AttachAsModified(currentGewonnenvoucher, this.ChangeSet.GetOriginal(currentGewonnenvoucher));
        }

        public void DeleteGewonnenvoucher(Gewonnenvoucher gewonnenvoucher)
        {
            if ((gewonnenvoucher.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(gewonnenvoucher, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.Gewonnenvoucher.Attach(gewonnenvoucher);
                this.ObjectContext.Gewonnenvoucher.DeleteObject(gewonnenvoucher);
            }
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'sysdiagrams' query.
        public IQueryable<sysdiagrams> GetSysdiagrams()
        {
            return this.ObjectContext.sysdiagrams;
        }

        public void InsertSysdiagrams(sysdiagrams sysdiagrams)
        {
            if ((sysdiagrams.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(sysdiagrams, EntityState.Added);
            }
            else
            {
                this.ObjectContext.sysdiagrams.AddObject(sysdiagrams);
            }
        }

        public void UpdateSysdiagrams(sysdiagrams currentsysdiagrams)
        {
            this.ObjectContext.sysdiagrams.AttachAsModified(currentsysdiagrams, this.ChangeSet.GetOriginal(currentsysdiagrams));
        }

        public void DeleteSysdiagrams(sysdiagrams sysdiagrams)
        {
            if ((sysdiagrams.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(sysdiagrams, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.sysdiagrams.Attach(sysdiagrams);
                this.ObjectContext.sysdiagrams.DeleteObject(sysdiagrams);
            }
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Voucher' query.
        public IQueryable<Voucher> GetVoucher()
        {
            return this.ObjectContext.Voucher;
        }

        public void InsertVoucher(Voucher voucher)
        {
            if ((voucher.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(voucher, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Voucher.AddObject(voucher);
            }
        }

        public void UpdateVoucher(Voucher currentVoucher)
        {
            this.ObjectContext.Voucher.AttachAsModified(currentVoucher, this.ChangeSet.GetOriginal(currentVoucher));
        }

        public void DeleteVoucher(Voucher voucher)
        {
            if ((voucher.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(voucher, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.Voucher.Attach(voucher);
                this.ObjectContext.Voucher.DeleteObject(voucher);
            }
        }
    }
}


